<?     
      
$info_width  = $info_more=="" ? 230 : "100%";     
$title_width = $info_more=="" ? "220px" : "80%";     
$subject= $header["subject"];        
$from   = $header["from"];      
$date   = $header["date"];      
$refs   = $header["references"];      
$type   = $header["content-type"];      
$code   = $header["content-transfer-encoding"];      
      
$groups = explode(',', $header["newsgroups"]);      
$ext    = "";     
$make_param = preg_replace ("/([\s|\d|\]|\]])/", "*", $subject);     
      
preg_match("/\"*(\S+\.\w{3})/", $header["subject"], $tmp);      
          
$is_text_message = strpos($type,"charset=")!==false;     
$is_text_message = $is_text_message || $code == "";     
         
$image_test = preg_match("/(\w+).*(jpeg|jpg|gif|png)/i",$subject,$image_map);     
$fn_test    = preg_match('/>*"*(\S+).(jpeg|jpg|gif|png)/i',$subject,$image_fn);      
$fx_test    = preg_match('/"*(.*)[.](\w{3})/',$subject,$image_fx);     
$multi_test = preg_match("/[(](\d+)\/+(\d+)[)]/", $subject, $multi_arr);      
if ($fn_test)     
{     
   $name = $image_fn[0];     
}     
else     
{     
   $name = $subject;     
}     
if ($fx_test)     
{     
   $ext = $image_fx[1];     
}      
      
$name = $tmp[1];     
       
if (strlen($info_more) > 0)       
{      
    $wrapped_subject = htmlentities ($subject);     
         
    print "<div style='margin-top:6px;margin-bottom:2px;padding:2px;'>      
         
     <span style='margin:2px;padding:4px;border:solid 1px teal;background-color:";      
    print "#66FF99'><img align='absmiddle' src='image.php?i=d'      
                    ><a href=\"javascript:load_article_list()\" style='color:#006633'>Article List</a>   ";     
    print "</span>     
         
     <span style='margin:2px;padding:4px;border:solid 1px teal;background-color:";      
    print "#66FF99'><img align='absmiddle' src='image.php?i=back'      
                    ><a href=\"javascript:nn.advance('".$m."',-1)\" style='color:#006633'>Prev Article</a>   ";     
    print "</span>     
         
     <span style='margin:2px;padding:4px;border:solid 1px teal;background-color:";      
    print "#66FF99'><img align='absmiddle' src='image.php?i=next'      
                    ><a href=\"javascript:nn.advance('".$m."',1)\" style='color:#006633'>Next Article</a>   ";     
    print "</span>     
         
     &nbsp;&nbsp;&nbsp;     
    <span id='imsg' style='font:10pt \"Times New Roman\"'></span>     
         
    </div>";         
}     
else     
{     
    $wrapped_subject = wrap_str($subject, 35);     
}     

print "<table width='" . $info_width . "' >";                                                 
print "<tr>";       
print "<td colspan='2' nowrap bgcolor='#f0f0f0' style='border:solid 1px gray'     
       ><b style='font:8pt \"arial\";color:black'>" . $wrapped_subject . "</b></td>";      
print "</tr>";      
print "<tr>";      
print "<td align='right'><b>From</b></td>";      
print "<td width='100%' nowrap><div style='font:8pt tahoma'>" . $from["name"] . "&nbsp;";      
if (strlen($info_more) == 0)       
{      
    print "<br>";     
}     
print "<a href='mailto:".$from["email"]."'>".$from["email"]."</a></div></td>";      
print "</tr>";      
print "<tr>";      
print "<td align='right'><b>Date</b></td>";      
print "<td width='100%' nowrap><div style='font:8pt tahoma'>" . $date. "</div></td>";      
print "</tr>"; /*     
print "<tr>";      
print "<td align='right'><b>Type</b></td>";      
print "<td width='100%' nowrap><div style='font:8pt tahoma'>" . htmlentities($refs) . "</div></td>";      
print "</tr>"; */     
print "<tr>";      
if (strlen($info_more) > 0)       
{     
    print "<td nowrap align='right'><b>Groups</b></td><td>";     
}     
else     
{     
    print "<td nowrap colspan='2'>";     
}     
      
foreach ($groups as $group)      
{      
    print "<div>&nbsp;<a href='".$href."?nntp=".$nntp_server."&g=$group'>$group</a></div>";      
}      
print "</td>";      
print "</tr>";      
print "</table>";       
        
$mpg_test = preg_match("/\.(mpg|mpeg|mp4|mp3|m4a|wmv|mov)[^\.]\"*\s*\W*/i", $subject, $mpg);     

if ($mpg_test)     
{     
  $file_type = preg_replace (     
                array("/(mpg|mpeg|wmv)/i","/(mp3|m4a)/i"),     
                array("Windows Media","MP3 Audio"),     
                $mpg[1]      
                );     
  print "<div align='left'>&nbsp;<img src='images/fw.png' border='0' align=absmiddle     
         >&nbsp;<a href='".$href."?sub=nzb&nntp=".$nntp_server."&nzb=" . $m . "&art_group=" . get_request("art_group") . "&art_subj=" . base64_encode($subject) . "'     
                  target='_blank'><b>Preview ".$file_type."</b></a></div>";      
   # ?sub=nzb&nzb=1481668&art_group=alt.binaries.multimedia.erotica.interracial&art_subj=-+54498007.MP4+(01/13)+|+[+4374k]+|&nntp=colossus-east.usenet.com       
}     
      
      
$test_image = strpos (parse_MIME_header ($subject), "image");     
$test_text  = strpos (parse_MIME_header ($subject), "text/plain");      
                
$multi_test = multipart_lookup ($subject, $nntp, true);      
print "";      
      
print "<div align=left>";        

print "<table width='" . $info_width . "'>";     
if ($multi_test)      
{      
        print "<tr>";     
        print "<td id='dmulti' colspan='2' bgcolor='yellow' style='border:solid 1px silver'>     
                <img src='image.php?i=download' align=absmiddle>&nbsp;<a      
                href='".$href."?nntp=".$nntp_server."&a=nzb&message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
                >Export</a> " . floor($multi_test) . " attachments as NZB file<br>";     
        print "</td>";     
        print "</tr>";      
}     
$multi_test = multifile_lookup ($subject, $nntp, true);     
if ($multi_test)      
{      
    print "<tr>";     
    print "<td colspan='2' bgcolor='yellow' style='border:solid 1px silver'>     
    <img src='images/ZIP_sm.gif' align=absmiddle>&nbsp;<a target='_blank'       
              href='nzb.php?nntp=".$nntp_server."&a=gnzb&message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
            >Export</a> ";     
    print $multi_test["count"] . "-part file series as NZB file <br>";     
    print "</td>";     
    print "</tr>";      
}     
print "</table>";     
print "</div>";     
         
if ($image_test)     
{     
    print "<div align=left>     
         <table>     
               <tr>     
               <td align='right'><img align=absmiddle src='images/webcam.gif'>     
               </td>     
               <td><a target=_blank href='".$href."?nntp=".$nntp_server."&message_id=" . $m . "&art_group="      
                                                                      . get_request("art_group")      
                                                                      . "&a=slide'     
                    >View all images like this as a slideshow</a>     
               </td>     
               </tr>      
               <tr>     
               <td align='right'><img align=absmiddle src='images/pano-nudger.png'>     
               </td>     
               <td><a      
                   onclick=\"window.open('".$href."?message_id=" . $m      
                                                                      . "&art_group=" . get_request("art_group")      
                                                                      . "&a=bookmark', '', 'width=200,height=240,statusbar=no')\"     
                    href='#'>Bookmark this image</a>     
               </td>     
               </tr>      
            </table>      
      </div>";      
}     
 /*     
print '<div align="left"><form action="newsgroups.php" target="blank">     
<input type="hidden" name="art_group"   value="'.$group_name.'">     
<input type="hidden" name="message_id" value="'.$m.'">     
<input type="hidden" name="a" value="tnzb">     
<input type="text" size="10" name="pat" value="">     
<input type="submit" value="Custom">     
</form></div>';*/     
if (strlen($info_more) > 0)       
{     
    print "<hr noshade size='1'>"  ;      
    print "&nbsp;&nbsp;&nbsp;Message-ID: <font color='green' face='arial'>" . htmlentities ($header["message-id"]) . "</font>";      
           
    $part_count = 1;     
    if ($multi_test&&count($multi_arr)>0)     
    {      
        $part_index  = $multi_arr[1];     
        $part_count  = $multi_arr[2];     
    }      
       
    $ext_test = preg_match("/\.(\w+)[^\.]\"*\s*\W*/i", $subject, $mpg);     
    $header = array();     
    if ($is_text_message&&$part_count==1)     
    {     
        $body = $nntp->get_body_only ($m);         
        if ( preg_match("/^=ybegin.*name=([^\r\n]+)/im", $body, $header))     
        {      
        }      
        else if ( preg_match("/^begin\s+\d{3}\s+(.*)$/im", $body, $header) )     
        {      
        }      
    }     
         
    if (count ($header) > 0)     
    {     
        $image_test = preg_match("/(\w+).*(jpeg|jpg|gif|png)/i", $header[1], $image_map);     
        if ($image_test)     
        {     
             print "<br>&nbsp;&nbsp;&nbsp;Attachment: <a href='" . $href . "?message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
                         target='_blank'>" . trim($header[1]) . "</a>";       
             print "<br><br><center>";      
             print "<!-- <img onload='desktop_background_resize()'      
                    align=center border='1'     
                    alt='" . $m . "'     
                    onerror='this.style.display=\"none\"'     
                    src='" . $href . "?pp_w=300&message_id=" . $m . "&art_group=" . get_request("art_group") . "'> -->";     
             print "</center>";     
        }     
        else     
        {     
             print "<div style='margin:2px;padding:4px;border:solid 1px gray;background-color:#FFFFCC;width:230px;'>";     
             print "Attachment: <a href='" . $href . "?message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
                             target='_blank'>" . trim($header[1]) . "</a>";      
             print "</div>";     
        }     
    }     
    else     
    {           
           print "<br>";     
           if ($part_count==1)     
           {     
               print "&nbsp;&nbsp;&nbsp;Message text:      
               <div style='width:95%;margin:2px;padding:10px;border:solid 1px gray;background-color:#FFFFCC;overflow:hidden'>     
                      <xmp>";     
               print $body;     
               print "</xmp></div>";     
           }     
           else     
           {     
               print "<div style='margin:2px;padding:4px;border:solid 1px gray;background-color:#FFFFCC;width:230px;'>";     
               print "&nbsp;&nbsp;&nbsp;Part " .  $part_index . " of a " . $part_count . "-part message.";     
               print "</div><br><br>";     
           }      
                
    }     
         
         
}       
else     
{       
         
    print "<div align='center' style='margin-top:6px;margin-bottom:2px;padding:2px;'>      
          
     <a href=\"javascript:nn.advance('".$m."',-1)\"><img border='0' align='absmiddle' src='image.php?i=back'      
                    ></a>   ";     
                         
    print "<a border='0' href=\"javascript:nn.advance('".$m."',1)\"><img align='absmiddle' src='image.php?i=next'      
                     border=0></a>        
          
    </div>";          
}     
/*     
else if ($is_text_message)     
{     
     $body = $nntp->get_body_only ($m);       
          
    if ( preg_match("/^=ybegin.*name=([^\\r\\n]+)/im", $body, $header))     
    {     
        $body = "Attachment: <a href='" . $href . "?message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
                             target='_blank'>" . trim($header[1]) . "</a>";      
    }      
    else if ( preg_match("/^begin\s+\d{3}\s+(.*)$/im", $body, $header) )     
    {     
        $body = "Attachment: <a href='" . $href . "?message_id=" . $m . "&art_group=" . get_request("art_group") . "'     
                             target='_blank'>" . trim($header[1]) . "</a>";      
    }      
         
     print "<div style='margin:2px;padding:2px;border:solid 1px gray;background-color:#FFFFCC;width:230px;'>";     
     print chop_str ($body, 255);     
     print "</div>";     
}*/     
      
      
    print "<font color=gray>&nbsp;" . $m . ": " . $nntp_server . "<br>&nbsp;"  . get_request("art_group") . "</font>";     
         
#$tmp=$nntp->search_newsgroup (1, $make_param);     
#print count ($tmp["articles"]) . " like this";     
# $exec_end = exact_millisec() ;       
# $exec_span = $exec_end-$exec_begin ;      
# print "4) " . $exec_span . "<br>";          
$nntp->quit();         
exit;      
?>